#region License

// This file is part of Grawlix.
// 
// Grawlix is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// Grawlix is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// License along with Grawlix.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

using System;
using Castle.Windsor;

namespace Grawlix.Services
{
	/// <summary>
	/// A type of object that abstracts game loading.
	/// </summary>
	public interface IGameLoader
	{
		/// <summary>
		/// The kernel that is currently active.
		/// </summary>
		/// <value>The kernel that is currently active, or null if none
		/// are ready.</value>
		IGameKernel CurrentKernel { get; }

		/// <summary>
		/// Gets a value indicating whether the user has requested to
		/// quit.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this the user has requested to quit;
		/// 	otherwise,
		/// <c>false</c>.
		/// </value>
		bool HasQuit { get; }

		/// <summary>
		/// Activates using the specified parent kernel.
		/// </summary>
		/// <param name="parentKernel">The kernel to use as parent.</param>
		void Activate(IWindsorContainer parentKernel);

		/// <summary>
		/// Cancels the current load.
		/// </summary>
		void CancelLoad();

		/// <summary>
		/// Connects to a specified host.
		/// </summary>
		/// <param name="hostName">The name or IP address of the host.
		/// </param>
		/// <param name="port">The host's port.</param>
		/// <exception cref="ArgumentNullException"><c>hostName</c> is
		/// null.</exception>
		/// <exception cref="NotImplementedException">Loading a network
		/// game is not yet supported.</exception>
		/// <exception cref="ArgumentException">port must be between 1
		/// and 65535, inclusive.</exception>
		void Connect(string hostName, int port);

		/// <summary>
		/// Hosts the world with the specified name.
		/// </summary>
		/// <param name="worldName">Name of the world to load.</param>
		/// <param name="port">The port to host on.</param>
		/// <exception cref="ArgumentNullException"><c>worldName</c> is
		/// null.</exception>
		/// <exception cref="NotImplementedException">Loading a network
		/// game is not yet supported.</exception>
		/// <exception cref="ArgumentException">port must be between 1
		/// and 65535, inclusive.</exception>
		void Host(string worldName, int port);

		/// <summary>
		/// Loads the local game.
		/// </summary>
		void LoadLocal();

		/// <summary>
		/// Indicate that the game should quit.
		/// </summary>
		void Quit();

		/// <summary>
		/// Updates the current game based on the time elapsed.
		/// </summary>
		/// <param name="elapsed">The elapsed time since last update.
		/// </param>
		/// <returns>The game to switch to.</returns>
		void Update(TimeSpan elapsed);
	}
}